package com.tangsm.spring.mvc.mybatis.enums;

/**
 * 使用枚举表述常量数据字典
 */
public enum AppointStateEnum {
	/**
	 * 预约成功
	 */
	SUCCESS(1, "预约成功"),
	/**
	 * 库存不足
	 */
	NO_NUMBER(0, "库存不足"),
	/**
	 * 重复预约
	 */
	REPEAT_APPOINT(-1, "重复预约"),
	/**
	 * 系统异常
	 */
	INNER_ERROR(-2, "系统异常");

	private final int state;

	private final String stateInfo;

	AppointStateEnum(int state, String stateInfo) {
		this.state = state;
		this.stateInfo = stateInfo;
	}

	public int getState() {
		return state;
	}

	public String getStateInfo() {
		return stateInfo;
	}

	public static AppointStateEnum stateOf(int index) {
		for (AppointStateEnum state : values()) {
			if (state.getState() == index) {
				return state;
			}
		}
		return null;
	}
}
